﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Collections.Generic;
using System.Windows.Data;
using Infragistics.Controls.Grids.Primitives;

namespace Infragistics
{
    public class MobilePhone
    {

        private static ObservableCollection<DataItem> dataItems;

        private static ObservableCollection<DataItem> CreateData()
        {
            return new ObservableCollection<DataItem>
            {
                new DataItem
                {
                    ID = 4294967296,
                    StartDate = new DateTime(2010,1,11),
                    StopDate = new DateTime(2011,1,11)
                },
                new DataItem
                {
                    ID = 9222036854775808,
                    StartDate = new DateTime(2010,5,19),
                    StopDate = new DateTime(2011,1,19)
                },
                 new DataItem
                {
                    ID = 4294967296,
                    StartDate = new DateTime(2011,1,11),
                    StopDate = new DateTime(2012,1,11)
                },
                new DataItem
                {
                    ID = 9222036854775808,
                    StartDate = new DateTime(2011,5,19),
                    StopDate = new DateTime(2012,1,19)
                }
            };


        }


        public static ObservableCollection<DataItem> DataItems
        {
            get
            {
                if (dataItems == null)
                    dataItems = CreateData();
                return dataItems;
            }
        }

    }

    public class DataItem : INotifyPropertyChanged
    {
        private long _id;
        public long ID
        {
            get { return _id; }
            set
            {
                if (_id != value)
                {
                    this._id = value;
                    OnPropertyChanged("ID");
                }
            }

        }
        private DateTime _startDt;
        public DateTime StartDate
        {
            get { return _startDt; }
            set
            {
                if (_startDt != value)
                {
                    this._startDt = value;
                    OnPropertyChanged("StartDate");
                }
            }

        }
        private DateTime _stopDt;
        public DateTime StopDate
        {
            get { return _stopDt; }
            set
            {
                if (_stopDt != value)
                {
                    this._stopDt = value;
                    OnPropertyChanged("StopDate");
                }
            }

        }
        public event PropertyChangedEventHandler PropertyChanged;
        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }


    }


    public class IDConverter : IValueConverter
    {


        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            long id;
            if (value.GetType() == typeof(FilterValueProxy))
            {
                FilterValueProxy fvp = (FilterValueProxy)value;
                if (fvp.Column.Key == "ID")
                    id = (long)fvp.Value;
                else
                    return fvp.Value;
            }
            else
                id = (long)value;

            string desc = null;
            switch (id)
            {
                case 4294967296:
                    desc = "Value Conversion 1";
                    break;
                case 9222036854775808:
                    desc = "Value Conversion 2";
                    break;
            }
            return desc;
        }

        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {

            return value;
        }
    }
}
